<?php
// FEATURED BOX
function featured( $atts, $content = null ) {
	extract(shortcode_atts(array(
		'title'	=> '',
		'color'	=> '',
		'bg'		=> 'E9E9E9',
		'ribbon'	=> '',
		'width'	=> 'auto',
		'height'	=> 'auto',
		'float'	=> 'none'
	), $atts));
	// float
	if ($float=="left") {
		$fl = 'float:left; margin:0 10px 0 0; ';
	} 
	elseif ($float=="right") {
		$fl = 'float:right; margin:0 0 0 10px; ';
	}
	// ribbon
	if ($ribbon) { 
		$home = get_bloginfo('template_url');
		$r = '<div class="ribbon"><img src="'.$home.'/images/ribbons/'.$ribbon.'.png" alt=""/></div>';
	} 
	// title
	if ($title) {$t = '<div class="t" style="background-color:#'.$bg.'; color:#'.$color.'">'.$title.'</div>' ;
	}
	// select the class
	if ($title) {$class = "c";} else {$class = "c2";};
	$before = '
		<div class="featured" style="'.$fl.'width:'.$width.'px">
			'.$r.$t.'
		<div class="'.$class.'" style="height:'.$height.'px">
	';
	$after = '</div></div>';
	return $before.do_shortcode($content).$after; 
	}
add_shortcode('featured', 'featured');

// PRICING BOX
function pricing( $atts, $content = null ) {
	extract(shortcode_atts(array(
		'ribbon'			=> '',
		'title'			=> '',
		'height'			=> 'auto',
		'price'			=> '',
		'period'			=> '',
		'button'			=> '',
		'button_color'	=> '8AA43C',
		'link'			=> '#',
		'tooltip'		=> ''
	), $atts));
	// ribbon
	if ($ribbon) { 
		$home = get_bloginfo('template_url');
		$r = '<div class="ribbon"><img src="'.$home.'/images/ribbons/'.$ribbon.'.png" alt=""/></div>';} 
	// title
	if ($title) {$t = '<h5>'.$title.'</h5>' ;};
	// price
	if ($price) {
		if ($period) {
			$prd = '<span> / '.$period.'</span>';
		}
		$prc = '<div class="prc">'.$price.$prd.'</div>';
	}
	if ($button) {
		$btn = '<a class="bigbutton tooltip" title="'.$tooltip.'" href="'.$link.'" style="background-color:#'.$button_color.'">'.$button.'</a>';
	}
	$before = '<div class="pricing" style="height:'.$height.'">'.$r.$t;
	$after = $prc.$btn.'</div>';
	return $before.do_shortcode($content).$after; 
	}
add_shortcode('pricing', 'pricing');

// DISABLE AUTOFORMATING POSTS
function my_formatter($content) {
	$new_content = '';
	$pattern_full = '{(\[raw\].*?\[/raw\])}is';
	$pattern_contents = '{\[raw\](.*?)\[/raw\]}is';
	$pieces = preg_split($pattern_full, $content, -1, PREG_SPLIT_DELIM_CAPTURE);
	foreach ($pieces as $piece) {
		if (preg_match($pattern_contents, $piece, $matches)) {
			$new_content .= $matches[1];
		} else {
			$new_content .= wptexturize(wpautop($piece));
		};
	};
	return $new_content;
}
remove_filter('the_content', 'wpautop');
remove_filter('the_content', 'wptexturize');
add_filter('the_content', 'my_formatter', 1);

// GREEN NOTE
function green_note( $atts, $content = null ) {
	$out = "<div class=\"green_note\">" .do_shortcode($content). "</div>";
	return $out; }
add_shortcode('green_note', 'green_note');

// BLUE NOTE
function blue_note( $atts, $content = null ) {
	$out = "<div class=\"blue_note\">" .do_shortcode($content). "</div>";
	return $out; }
add_shortcode('blue_note', 'blue_note');

// YELLOW NOTE
function yellow_note( $atts, $content = null ) {
	$out = "<div class=\"yellow_note\">" .do_shortcode($content). "</div>";
	return $out; }
add_shortcode('yellow_note', 'yellow_note');

// QUOTE
function quote( $atts, $content = null ) {
	extract(shortcode_atts(array(
		'author'		=> '',
	), $atts));
	$out = "<div class=\"bgt\"><div class=\"bgb\"><blockquote class=\"center\">" .do_shortcode($content). " <div class=\"a\">" .$author. "</div></blockquote></div></div>";
	return $out; }
add_shortcode('quote', 'quote');

// QUOTE LEFT
function quote_left( $atts, $content = null ) {
	extract(shortcode_atts(array(
		'author'		=> '',
	), $atts));
	$out = "<blockquote class=\"left\">" .do_shortcode($content). " <div class=\"a\">" .$author. "</div></blockquote>";
	return $out; }
add_shortcode('quote_left', 'quote_left');

// QUOTE RIGHT
function quote_right( $atts, $content = null ) {
	extract(shortcode_atts(array(
		'author'		=> '',
	), $atts));
	$out = "<blockquote class=\"right\">" .do_shortcode($content). " <div class=\"a\">" .$author. "</div></blockquote>";
	return $out; }
add_shortcode('quote_right', 'quote_right');

// DROP CAP
function dropcap( $atts, $content = null ) {
	return '<span class="dropcap">' . do_shortcode($content) . '</span>'; }
add_shortcode('dropcap', 'dropcap');

// HIGHLIGHT YELLOW
function yellow( $atts, $content = null ) {
	return '<span class="highlight_yellow">' . do_shortcode($content) . '</span>'; }
add_shortcode('yellow', 'yellow');

// HIGHLIGHT BLUE
function blue( $atts, $content = null ) {
	return '<span class="highlight_blue">' . do_shortcode($content) . '</span>'; }
add_shortcode('blue', 'blue');

// HIGHLIGHT GREEN
function green( $atts, $content = null ) {
   return '<span class="highlight_green">' . do_shortcode($content) . '</span>'; }
add_shortcode('green', 'green');

// GOOGLE CHARTS
function chart_shortcode( $atts ) {
	extract(shortcode_atts(array(
	    'data' => '',
	    'colors' => '',
	    'size' => '500x250',
	    'bg' => 'FFFFFF',
	    'title' => '',
	    'labels' => '',
	    'advanced' => '',
	    'type' => 'pie'
	), $atts));

	switch ($type) {
		case 'line' :
			$charttype = 'lc'; break;
		case 'xyline' :
			$charttype = 'lxy'; break;
		case 'sparkline' :
			$charttype = 'ls'; break;
		case 'meter' :
			$charttype = 'gom'; break;
		case 'scatter' :
			$charttype = 's'; break;
		case 'venn' :
			$charttype = 'v'; break;
		case 'pie' :
			$charttype = 'p3'; break;
		case 'pie2d' :
			$charttype = 'p'; break;
		default :
			$charttype = $type;
		break;
	}

	if ($title) $string .= '&chtt='.$title.'';
	if ($labels) $string .= '&chl='.$labels.'';
	if ($colors) $string .= '&chco='.$colors.'';
	$string .= '&chs='.$size.'';
	$string .= '&chd=t:'.$data.'';
	$string .= '&chf=bg,s,'.$bg.'';

	return '<img title="'.$title.'" src="http://chart.apis.google.com/chart?cht='.$charttype.''.$string.$advanced.'" alt="'.$title.'" />';
}
add_shortcode('chart', 'chart_shortcode');

// TABS 1-10
function tabs( $atts, $content = null ) {
	extract(shortcode_atts(array(
		'tab1'	=> '',
		'tab2'	=> '',
		'tab3'	=> '',
		'tab4'	=> '',
		'tab5'	=> '',
		'tab6'	=> '',
		'tab7'	=> '',
		'tab8'	=> '',
		'tab9'	=> '',
		'tab10'	=> '',
	), $atts));
	if ($tab1<>"") { $t1 = "<li><a href=\"#\"><span>".$tab1."</span></a></li>"; }
	if ($tab2<>"") { $t2 = "<li><a href=\"#\"><span>".$tab2."</span></a></li>"; }
	if ($tab3<>"") { $t3 = "<li><a href=\"#\"><span>".$tab3."</span></a></li>"; }
	if ($tab4<>"") { $t4 = "<li><a href=\"#\"><span>".$tab4."</span></a></li>"; }
	if ($tab5<>"") { $t5 = "<li><a href=\"#\"><span>".$tab5."</span></a></li>"; }
	if ($tab6<>"") { $t6 = "<li><a href=\"#\"><span>".$tab6."</span></a></li>"; }
	if ($tab7<>"") { $t7 = "<li><a href=\"#\"><span>".$tab7."</span></a></li>"; }
	if ($tab8<>"") { $t8 = "<li><a href=\"#\"><span>".$tab8."</span></a></li>"; }
	if ($tab9<>"") { $t9 = "<li><a href=\"#\"><span>".$tab9."</span></a></li>"; }
	if ($tab10<>"") { $t10 = "<li><a href=\"#\"><span>".$tab10."</span></a></li>"; }
	$id = rand(0,9999);
	$out = "
		<div id=\"id".$id."\">
			<ul class=\"short-tabs\">
				".$t1."".$t2."".$t3."".$t4."".$t5."".$t6."".$t7."".$t8."".$t9."".$t10."
			</ul>
			<div class=\"panes\">
				".do_shortcode($content)."
			</div>
		</div>
		<div class=\"clear\"><!-- --></div>
		<script>$(function() { $('div#id".$id." ul.short-tabs').tabs('div#id".$id." div.panes > div', {}); });</script>
	";
	return $out; }
add_shortcode('tabs', 'tabs');

// SLIDES 1-10
function slide1( $atts, $content = null ) {
	$out = "<div>".do_shortcode($content)."</div>"; return $out; }
add_shortcode('slide1', 'slide1');

function slide2( $atts, $content = null ) {
	$out = "<div>".do_shortcode($content)."</div>"; return $out; }
add_shortcode('slide2', 'slide2');

function slide3( $atts, $content = null ) {
	$out = "<div>".do_shortcode($content)."</div>"; return $out; }
add_shortcode('slide3', 'slide3');

function slide4( $atts, $content = null ) {
	$out = "<div>".do_shortcode($content)."</div>"; return $out; }
add_shortcode('slide4', 'slide4');

function slide5( $atts, $content = null ) {
	$out = "<div>".do_shortcode($content)."</div>"; return $out; }
add_shortcode('slide5', 'slide5');

function slide6( $atts, $content = null ) {
	$out = "<div>".do_shortcode($content)."</div>"; return $out; }
add_shortcode('slide6', 'slide6');

function slide7( $atts, $content = null ) {
	$out = "<div>".do_shortcode($content)."</div>"; return $out; }
add_shortcode('slide7', 'slide7');

function slide8( $atts, $content = null ) {
	$out = "<div>".do_shortcode($content)."</div>"; return $out; }
add_shortcode('slide8', 'slide8');

function slide9( $atts, $content = null ) {
	$out = "<div>".do_shortcode($content)."</div>"; return $out; }
add_shortcode('slide9', 'slide9');

function slide10( $atts, $content = null ) {
	$out = "<div>".do_shortcode($content)."</div>"; return $out; }
add_shortcode('slide10', 'slide10');

// TOGGLE
function toggle( $atts, $content = null ) {
	extract(shortcode_atts(array(
		'title'		=> '',
	), $atts));
	$out .= '<div class="toggle" style="background-position:left 12px;"><span>' .$title. '</span></div>';
	$out .= '<div class="toggle_content" style="display: none;">';
	$out .= '<div class="tc">';
	$out .= do_shortcode($content);
	$out .= '</div>';
	$out .= '</div>';
	return $out; }
add_shortcode('toggle', 'toggle');

// CLEAR
function clear( $atts, $content = null ) {
   return '<div class="clear"></div>'; }
add_shortcode('clear', 'clear');

// LINE
function line( $atts, $content = null ) {
   return '<div class="line"></div>'; }
add_shortcode('line', 'line');
?>
